package com.baselibrary.libs.View.defined.defined_listView;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;

import com.baselibrary.libs.R;
import com.baselibrary.libs.View.baseView.BaseView;
import com.baselibrary.libs.View.pullableview.PullToRefreshLayout.PullToRefreshLayout;
import com.baselibrary.libs.View.pullableview.PullableListView;
import com.baselibrary.libs.example.example_listView.View.ListView_example;
import com.baselibrary.libs.example.example_listView.interfaces.listViewCallBack;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by 35876 于萌萌
 * 创建日期: 17:59 . 2017年01月29日
 * 描述:可定制的listView
 * <p>
 * <p>
 * 备注:
 */

public class  Defined_listView<T> extends BaseView {
    List<T> list  = new ArrayList<T>();
    private PullableListView listView;
    private ListView_example mExample;
    private PullToRefreshLayout mRefresh_view;

    public Defined_listView(Context context) {
        super(context);
    }

    public Defined_listView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public Defined_listView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    public int getXml() {
        return R.layout.defined_listview;
    }

    @Override
    public void initView(View view) {
        mRefresh_view = (PullToRefreshLayout)view.findViewById(R.id.refresh_view);

        listView =(PullableListView)view.findViewById(R.id.listView);


    }

    public void initListener(PullToRefreshLayout.OnRefreshListener listener) {
        mRefresh_view.setOnRefreshListener(listener);
    }

    public ListView_example getExample() {
        return mExample;
    }

    public Defined_listView initListData(Context context, int type , List<T> list,listViewCallBack callBack) {
        mExample = new ListView_example(context, type, list, callBack);
        listView.setAdapter(mExample);
        return this;
    }


}
